@model user_entity
@{
    ViewData["Title"] = "修改用户";
}
@section Scripts{
<script src="~/js/xm-select.js"></script>
<script>
    layui.use(['colorpicker'], function(){
        var upload = layui.upload
        ,laydate = layui.laydate;

        //普通图片上传
        var uploadInst = upload.render({
            elem: '#test-upload-normal'
            ,url: '/v6admin/upload?module=avatar'
            ,before: function(obj){
                //预读本地文件示例，不支持ie8
                obj.preview(function(index, file, result){
                    $('#test-upload-normal-img').attr('src', result); //图片链接（base64）
                });
            }
            ,done: function(res){
                //如果上传失败
                if(res.code == 200) {
                    $("#avatar").val(res.data.path);
                    return layer.msg('上传成功');
                }
                else {
                    return layer.msg('上传失败');
                }
                //上传成功
            }
            ,error: function(){

            }
        });

        //日期选择器
        laydate.render({
          elem: '#date_of_birth'
          //,type: 'date' //type 默认为 date，所以可不填
        });
    });

    //立即执行函数
    $(function () {
        $.ajax({
            url:"/v6admin/api/dept_api/get_list",
            success: function(data){
                var demo1 = xmSelect.render({
                    el: '#demo1',
                    name: 'dept_id',
                    layVerify: 'required',
                    filterable: true,
                    radio: true,//单选模式
                    clickClose: true,//选中关闭
                    tree: {
                        strict: false,//非严格模式
                        show: true,
                        showFolderIcon: true,
                        showLine: true,
                        indent: 20,
                        expandedKeys: [ 1 ],
                    },
                    data: data
                });

                demo1.setValue([ @Model.dept_id ]);
            }
        });
    });
</script>
}
<div class="layui-card">
    <div class="layui-card-header">@ViewData["Title"]</div>
    <div class="layui-card-body" style="padding: 15px;">
        <form asp-action="edit" class="layui-form">
            <div asp-validation-summary="ModelOnly" class="text-danger"></div>

            <div class="layui-form-item">
                <div class="layui-col-inline">
                    <label class="layui-form-label">
                        <span class="layui-font-red">*</span>
                        选择角色
                    </label>
                    <div class="layui-input-inline">
                        <select asp-for="role_id" asp-items="@ViewData["role_list"] as List<SelectListItem>" lay-verify="required"></select>
                    </div>
                </div>
                <div class="layui-col-inline">
                    <label class="layui-form-label">部门</label>
                    <div class="layui-input-inline">
                        <div id="demo1" class="xm-select-demo"></div>
                    </div>
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-col-inline">
                    <label class="layui-form-label">
                        <span class="layui-font-red">*</span>
                        用户名
                    </label>
                    <div class="layui-input-inline">
                        <input asp-for="username" class="layui-input" readonly="readonly">
                    </div>
                </div>
            </div>

            <div class="layui-form-item">

                <div class="layui-col-inline">
                    <label class="layui-form-label">姓名</label>
                    <div class="layui-input-inline">
                        <input asp-for="real_name" class="layui-input">
                    </div>
                </div>

                <div class="layui-col-inline">
                    <label class="layui-form-label">身份证号</label>
                    <div class="layui-input-inline">
                        <input asp-for="card_id" class="layui-input">
                    </div>
                </div>

            </div>

            <div class="layui-form-item">
                <div class="layui-col-inline">
                    <label class="layui-form-label">手机号码</label>
                    <div class="layui-input-inline">
                        <input asp-for="mobile" class="layui-input">
                    </div>
                </div>
                <div class="layui-col-inline">
                    <label class="layui-form-label">职位</label>
                    <div class="layui-input-inline">
                        <input asp-for="post" class="layui-input">
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-col-md6">
                    <label asp-for="avatar" class="layui-form-label"></label>
                    <div class="layui-input-block">
                        <div class="layui-upload">
                            <input type="hidden" asp-for="avatar" />
                            <button type="button" class="layui-btn" id="test-upload-normal">上传头像</button>
                            <div class="layui-upload-list">
                                <img class="layui-upload-img" id="test-upload-normal-img" style="max-width: 240px;max-height: 240px;" src="@Model.avatar" />
                                <p id="test-upload-demoText"></p>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-col-inline">
                    <label class="layui-form-label">属性</label>
                    <div class="layui-input-block">
                        <input asp-for="is_lock" title="锁定" />
                        <input asp-for="is_leader_mailbox" title="领导信箱" />
                    </div>
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-col-inline">
                    <label asp-for="sort_rank" class="layui-form-label">
                        <span class="layui-font-red">*</span>
                        排序
                    </label>
                    <div class="layui-input-inline">
                        <input asp-for="sort_rank" lay-verify="required" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <label asp-for="date_of_birth" class="layui-form-label"></label>
                    <div class="layui-input-inline">
                        @{
                            string date_of_birth = "";
                            if (Model.date_of_birth.HasValue)
                            {
                                date_of_birth = Model.date_of_birth.Value.ToString("yyyy-MM-dd");
                            }
                        }
                        <input type="input" asp-for="date_of_birth" value='@date_of_birth' placeholder="yyyy-MM-dd" class="layui-input">
                    </div>
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-col-md6">
                    <label asp-for="intro" class="layui-form-label"></label>
                    <div class="layui-input-block">
                        <textarea asp-for="intro" class="layui-textarea"></textarea>
                    </div>
                </div>
            </div>

            <div class="layui-form-item layui-layout-admin">
                <div class="layui-input-block">
                    <div class="layui-footer" style="left: 0;">
                        <button class="layui-btn" lay-submit="">保存</button>
                        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>
